export function formatTimestamp(timestamp) {
    const now = Date.now();
    const diff = now - timestamp; // 计算时间差，单位为毫秒

    const minute = 60 * 1000; // 1分钟的毫秒数
    const hour = 60 * minute; // 1小时的毫秒数
    const day = 24 * hour; // 1天的毫秒数
    const month = 30 * day; // 1个月的毫秒数（假设每个月30天）
    const threeMonths = 3 * month; // 3个月的毫秒数

    if (diff < minute) {
        return "一分钟内";
    } else if (diff < hour) {
        const minutes = Math.floor(diff / minute);
        return `${minutes}分钟前`;
    } else if (diff < day) {
        const hours = Math.floor(diff / hour);
        return `${hours}小时前`;
    } else if (diff < month) {
        const days = Math.floor(diff / day);
        return `${days}天前`;
    } else if (diff < threeMonths) {
        const months = Math.floor(diff / month);
        return `${months}个月前`;
    } else {
        return null; // 超过3个月返回null
    }
}